<!--复选框-->
<template>
  <div class="example tableClass">
    <label class="relative button-block label-file">
      <span>上传文件</span>
      <input
        multiple
        @change="$upload.action($event, {success: submitData})"
        class="absolute input-file"
        type="file"/>
    </label>
    <table cellspacing="0">
      <tr>
        <th>1) 调用全局上传</th>
      </tr>
      <tr>
        <td><pre>{{explameCall}}</pre></td>
      </tr>
      <tr>
        <th>2) 参数例子</th>
      </tr>
      <tr>
        <td><pre>{{explameMethods}}</pre></td>
      </tr>
      <tr>
        <td>
          <zz-preview
            margin="10px 10px 0 0"
            v-for="file in list"
            :item="file"
            :info=true
            :key="file.id"
            :isAuth = true
            :th = 4
            imgWidth="185px" ></zz-preview>
        </td>
      </tr>
    </table>

  </div>
</template>

<script>

  export default {
    name: '',
    data () {
      return {
        replyFiles: [],
        list: [],
        explameCall: `<label class="relative button-block label-file">
          <span>上传文件</span>
          <input
            multiple
            @change="$upload.action($event, 参数， 是个对象, 下有栗子)"
            class="absolute input-file"
            type="file"/>
        </label>`,

        explameMethods:
          `{
            type: [] 上传类型 默认全部
            success： function 上传成功之后的 点击确定时的回调函数
            length: 999  文件最大上传数
            fileOwnerType: 2, // 上传人 1：个人 2：企业
            subSystem: 2 // 上传方 1：CCBIM 2：公司内部 3 第三方
          }`
      }
    },
    mounted () {
      this.query()
    },
    methods: {
      updateFileHandel (state) {
      },
      query () {
        let data = {
          'query.own_type': 2
        }
        this.$axios({
          method: 'post',
          url: `${this.$site.oaServer}/front/find_document.htm`,
          paginate: true,
          data: this.$qs.stringify(data, {indices: false})
        }).then(res => {
          if (res.data.errorMsg) {
            this.$message.error(res.data.errorMsg)
          } else {
            this.list = res.data.list
          }
        })
      },
      submitData (files) {
        let data = {
          'form.document_type': 2,
          'form.fileUuids': files
        }
        this.$axios({
          method: 'post',
          url: `${this.$site.oaServer}/front/add_document.htm`,
          data: this.$qs.stringify(data, {indices: false})
        }).then(res => {
          if (res.data.errorMsg) {
            this.$message.error(res.data.errorMsg)
          } else {
            this.$message.success(res.data.msg)
          }
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .example{
    padding: 20px;
    .example-left{
      float: left;
      width: 20%;
    }
    .example-right{
      float: right;
      width: 70%;
      background: #fff;
      padding: 20px;
    }
  }
</style>
